\hypertarget{funcoes_8cpp_source}{\section{funcoes.\-cpp}
}

\begin{DoxyCode}
00001 \textcolor{preprocessor}{#include "\hyperlink{funcoes_8hpp}{funcoes.hpp}"}
00002 
\hypertarget{funcoes_8cpp_source_l00003}{}\hyperlink{funcoes_8hpp_ad43ef2eaabab67fea716175982fd05e3}{00003} \textcolor{keywordtype}{void} \hyperlink{funcoes_8cpp_ad43ef2eaabab67fea716175982fd05e3}{solver}(\textcolor{keywordtype}{double} T0, \textcolor{keywordtype}{double} TM, \hyperlink{classvetor}{vetor} X0, \textcolor{keywordtype}{double} W, \textcolor{keywordtype}{double} PV, \hyperlink{classvetor}{vetor} (*F)(\textcolor{keywordtype}{
      double}, \hyperlink{classvetor}{vetor}, \textcolor{keywordtype}{double}))
00004 \{
00011     \textcolor{keywordtype}{double} h, t;
00012     h = 2*M\_PI/W;
00013     h = h/1000.0;
00014 
00015     \textcolor{keywordtype}{int} c = 0; \textcolor{comment}{// contador para a seção de Poincaré}
00016 
00017     ofstream rst(\textcolor{stringliteral}{"RST.txt"}); \textcolor{comment}{// Declaração e associação dos arquivos de texto
       aos seus respectivos objetos.}
00018     ofstream pfs(\textcolor{stringliteral}{"PFS.txt"});
00019     ofstream pcr(\textcolor{stringliteral}{"PCR.txt"});
00020 
00021     t = T0;
00022     \hyperlink{classvetor}{vetor} X(X0);
00023 
00024     \textcolor{keywordflow}{while}(t <= TM)
00025     \{
00026         rst << t << \textcolor{stringliteral}{"\(\backslash\)t"} << X << endl;
00027         \hyperlink{funcoes_8cpp_a369b864f7af6f22b6394788e2d3ffcd5}{RungeKutta4}(h, t, X, PV, F);
00028 
00029         \textcolor{keywordflow}{if}(t >= 0.5*TM)
00030         \{
00031             pfs << t << \textcolor{stringliteral}{"\(\backslash\)t"} << X << endl;
00032 
00033             \textcolor{keywordflow}{if}((c % 1000) == 0)
00034             pcr << X << endl;
00035         \}
00036     \}
00037 
00038     rst.close(); \textcolor{comment}{// Fechamento dos arquivos de texto}
00039     pfs.close();
00040     pcr.close();
00041 \}
00042 
\hypertarget{funcoes_8cpp_source_l00043}{}\hyperlink{funcoes_8hpp_a5092e9c0757122d977359e77b80b8cd4}{00043} \textcolor{keywordtype}{void} \hyperlink{funcoes_8cpp_a5092e9c0757122d977359e77b80b8cd4}{solverDBF}(\textcolor{keywordtype}{double} T0, \textcolor{keywordtype}{double} TM, \hyperlink{classvetor}{vetor} X0, \textcolor{keywordtype}{double} W, \textcolor{keywordtype}{double} PI, \textcolor{keywordtype}{double} PF, \textcolor{keywordtype}{
      int} S, \hyperlink{classvetor}{vetor} (*F)(\textcolor{keywordtype}{double}, \hyperlink{classvetor}{vetor}, \textcolor{keywordtype}{double}))
00044 \{
00053     \textcolor{keywordtype}{double} h, t;
00054     h = 2*M\_PI/W;
00055     h = h/1000.0;
00056     \textcolor{keywordtype}{int} c;
00057     \textcolor{keywordtype}{double} hp = (PF - PI)/S; \textcolor{comment}{// passo do parâmetro variável}
00058     ofstream dbf(\textcolor{stringliteral}{"DBF.txt"});
00059 
00060     \textcolor{keywordflow}{while}(PI <= PF)
00061     \{
00062         t = T0;
00063         \hyperlink{classvetor}{vetor} X(X0);
00064         c = 0;
00065 
00066         \textcolor{keywordflow}{while}(t <= TM)
00067         \{
00068             \hyperlink{funcoes_8cpp_a369b864f7af6f22b6394788e2d3ffcd5}{RungeKutta4}(h, t, X, PI, F);
00069 
00070             \textcolor{keywordflow}{if}((t >= 0.5*TM) && (c % 1000 == 0))
00071                 dbf << PI << \textcolor{stringliteral}{"\(\backslash\)t"} << X << endl;
00072             c++;
00073         \}
00074         PI += hp;
00075         dbf << endl;
00076     \}
00077     dbf.close();
00078 \}
00079 
\hypertarget{funcoes_8cpp_source_l00080}{}\hyperlink{funcoes_8hpp_a369b864f7af6f22b6394788e2d3ffcd5}{00080} \textcolor{keywordtype}{void} \hyperlink{funcoes_8cpp_a369b864f7af6f22b6394788e2d3ffcd5}{RungeKutta4}(\textcolor{keywordtype}{double} H, \textcolor{keywordtype}{double} &T, \hyperlink{classvetor}{vetor} &X, \textcolor{keywordtype}{double} PV, \hyperlink{classvetor}{vetor} (*F)(\textcolor{keywordtype}{double}, 
      \hyperlink{classvetor}{vetor}, \textcolor{keywordtype}{double}))
00081 \{
00086     \textcolor{keywordtype}{int} o = X.\hyperlink{classvetor_aead9a92bb6204813a59b007719b1a318}{retDim}();
00087     \hyperlink{classvetor}{vetor} k1(o), k2(o), k3(o), k4(o);
00088 
00089     k1 = H*F(T, X, PV);
00090     k2 = H*F(T + 0.5*H, X + 0.5*k1, PV);
00091     k3 = H*F(T + 0.5*H, X + 0.5*k2, PV);
00092     k4 = H*F(T + H, X + k3, PV);
00093 
00094     X += (k1 + 2.0*(k2 + k3) + k4)*(1.0/6.0);
00095     T += H;
00096 \}
00097 
\hypertarget{funcoes_8cpp_source_l00098}{}\hyperlink{funcoes_8hpp_acdba77a1b686ff7d77d9b09e5f13fccb}{00098} \textcolor{keywordtype}{double} \hyperlink{funcoes_8cpp_acdba77a1b686ff7d77d9b09e5f13fccb}{Rand}(\textcolor{keywordtype}{double} a, \textcolor{keywordtype}{double} b)     \{    srand (time(NULL));    \textcolor{keywordflow}{return} (b - a)*
      (rand() / double(RAND\_MAX)) + a;     \}
\end{DoxyCode}
